package com.example.xunjian.adapter;

import java.util.List;

import com.example.xunjian.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

public class MenuAdapter extends BaseAdapter {
	private Context context;
	private List<String> list;

	public MenuAdapter(Context context, List<String> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		ViewHolder holder;
		if (convertView != null && convertView instanceof ListView) {
			view = convertView;
			holder = (ViewHolder) view.getTag();
		} else {
			view = View.inflate(context, R.layout.menu_list_view, null);
			holder = new ViewHolder();
			holder.listView = (ListView) view.findViewById(R.id.menu_list_view);
			view.setTag(holder);
		}
		String value = list.get(position);

		return view;
	}

	static class ViewHolder {
		ListView listView;
	}
}
